import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-04-14
 * Time: 8:22
 */
public class Demo1{
    private  static AtomicInteger count=new AtomicInteger(0);
    public static void main(String[] args) {
        Thread t1=new Thread(()->{
            for (int i = 0; i <50000 ; i++) {
                //count.getAndDecrement();//count++
                count.incrementAndGet();//++count
            }
        });
        Thread t2=new Thread(()->{
            for (int i = 0; i < 50000; i++) {
                count.getAndIncrement();
            }
        });
            t1.start();
            t2.start();
            try{
                t1.join();
                t2.join();
            }catch (InterruptedException e){
                e.printStackTrace();
            }

        System.out.println("count= " +count);

    }
}
